<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/backend/common/taglib.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/backend/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>后台管理工作平台</title>
<link rel="stylesheet" href="common/page.css" type="text/css"></link>
<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/engine.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/util.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/dwr/interface/uRMService.js"></script>
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(function(){
	$("input[name=submit]").click(function(){
		$("#distributeForm").submit();
		//window.close();
	});
})

function addOrUpdatePermission(obj){
	dwr.engine.setAsync(false);
alert(obj.getAttribute('moduleId'));

	/*uRMService.saveOrUpdatePermission(
			'user',
			${id},
			obj.moduleId,
			obj.permission,
			obj.checked
	);*/
	
	
}

</script>
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="24" bgcolor="#353c44"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="6%" height="19" valign="bottom"><div align="center"><img src="images/tb.gif" width="14" height="14" /></div></td>
                <td width="94%" valign="bottom"><span class="STYLE1">模块列表</span></td>
              </tr>
            </table></td>
            <td>
            	<div align="right">
            	 <span class="STYLE1">
	             
	             </span>
	             <span class="STYLE1"> &nbsp;</span>
             	</div>
             </td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td>

    <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#a8c7ce">
      <tr>
		<td height="20" bgcolor="#FFFFFF" class="STYLE19">顶级模块</td>			
		<td height="20" bgcolor="#FFFFFF" class="STYLE19">二级模块</td>
		<td height="20" bgcolor="#FFFFFF" class="STYLE19">权限</td>

		<td height="20" bgcolor="#FFFFFF" class="STYLE19">启用</td>
	  </tr>

      <c:forEach items="${moduleList}" var="module">
	    <tr>
	      <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center">${module.name }</div></td>
	      <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center"></div></td>
	      <td height="20" bgcolor="#FFFFFF" class="STYLE19">
		      <div align="center">
		      	<input type="checkbox" id="${module.id }_C" onclick="addOrUpdatePermission(this)" moduleId="${module.id }" permission="C">增
				<input type="checkbox" id="${module.id }_R" onclick="addOrUpdatePermission(this)" moduleId="${module.id }" permission="R">查
				<input type="checkbox" id="${module.id }_U" onclick="addOrUpdatePermission(this)" moduleId="${module.id }" permission="U">改
				<input type="checkbox" id="${module.id }_D" onclick="addOrUpdatePermission(this)" moduleId="${module.id }" permission="D">删
		      </div>
	      </td>
	      <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center">
			<input type="checkbox" id="${module.id }_USE" onclick="usePermission(this)" moduleId="${module.id }">
		</div></td>
	    </tr>
      
	      <c:forEach items="${module.children}" var="child">
		    <tr>
		      <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center"></div></td>
		      <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center">${child.name }</div></td>
		      <td height="20" bgcolor="#FFFFFF" class="STYLE19">
			      <div align="center">
			      	<input type="checkbox" onclick="addOrUpdatePermission(this)" moduleId="${child.id }" permission="C">增
					<input type="checkbox" onclick="addOrUpdatePermission(this)" moduleId="${child.id }" permission="R">查
					<input type="checkbox" onclick="addOrUpdatePermission(this)" moduleId="${child.id }" permission="U">改
					<input type="checkbox" onclick="addOrUpdatePermission(this)" moduleId="${child.id }" permission="D">删
			      </div>
		      </td>
		      <td height="20" bgcolor="#FFFFFF" class="STYLE19"><div align="center">
				<input type="checkbox" id="${child.id }_USE" onclick="usePermission(this)" moduleId="${child.id }">
			</div></td>
		    </tr>
	      </c:forEach>
	
		</c:forEach>
    </table>


    </td>
  </tr>
</table>
</body>
</html>

